#ifndef __DSTH_TIMESTAMP_H__
#define __DSTH_TIMESTAMP_H__

#include <string>
#include "DSTHType.h"

namespace dsth {

// mostly copy from muduo
class Timestamp {
public:
    static Timestamp GetNowTime();
    Timestamp() : micro_second_(0) {}
    explicit Timestamp(int64_t micro_second) : micro_second_(micro_second) {}
    std::string ToString() const;
    std::string ToFomattedString() const;
    int64_t GetMicroSecondsSinceEpoch() const { return micro_second_; }
    static const int kMicroSecondsPerSecond = 1000 * 1000;
private:
    int64_t micro_second_;
};

inline int64_t TimeDifference(Timestamp high, Timestamp low) {
    return high.GetMicroSecondsSinceEpoch() - low.GetMicroSecondsSinceEpoch();
}

inline Timestamp AddTime(Timestamp timestamp, int64_t seconds) {
    int64_t delta = (seconds * Timestamp::kMicroSecondsPerSecond);
    return Timestamp(timestamp.GetMicroSecondsSinceEpoch() + delta);
}

} // namespace
#endif // __DSTH_TIMESTAMP_H__
